﻿using System.Windows.Controls;
using System.Windows.Navigation;
using StartupSolution.ViewModel;
using Infragistics.Controls.Grids;

namespace StartupSolution.Views.Grids
{
    public partial class HieararchicalEditing : Page
    {
        public HieararchicalEditing()
        {
            InitializeComponent();

            this.Loaded += new System.Windows.RoutedEventHandler(HieararchicalEditing_Loaded);
        }

        void HieararchicalEditing_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            /// <summary> 
            /// This method will load data from a XML document and populate it as XamGrid ItemSource
            /// </summary>
            LoadData();
        }

        private void LoadData()
        {

            // Set the ItemsSource to generate the columns.
            dataGrid.ItemsSource = Util.CreateCategoriesAndProducts();

            // TODO: Enable editing in XamGrid control
            // Editing
            // This code is presented in the XAML page.
            // If you want to implement the editing functionality in the code-behind, comment the editing part in the XAML page.
            // dataGrid.EditingSettings.AllowEditing = EditingType.Row;
            // dataGrid.EditingSettings.IsEnterKeyEditingEnabled = true;
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
    }
}
